package daily.may0527;
import java.util.ArrayList;
import java.util.List;

public class UseForLoopTraverseTest {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张强");
        list.add("张三丰");
        //创建含有“张”的集合
        List<String> zhangList = new ArrayList<>();
        for (String name : list) {
            if (name.startsWith("张")) {
                zhangList.add(name);
            }
        }
        //创建不仅姓张还是三个字的集合
        List<String> shortList = new ArrayList<>();
        for (String name : zhangList) {
            if (name.length() == 3) {
                shortList.add(name);
            }
        }
        //打印过滤后的集合
        for (String name : shortList) {
            System.out.println(name);
        }
    }
}
